/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sinosoft.gateway.filter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 *
 * @author root
 */
@Component
@ConfigurationProperties(prefix = "spring.cloud.gateway")
public class GProperties {
    Logger logger = LoggerFactory.getLogger(getClass());
    /**
     * 监控中心和swagger需要访问的url
     */
    private static final String[] ENDPOINTS = { "/**/actuator/health", "/**/actuator/env", "/**/actuator/metrics/**",
            "/**/actuator/trace", "/**/actuator/dump", "/**/actuator/jolokia", "/**/actuator/info",
            "/**/actuator/logfile", "/**/actuator/refresh", "/**/actuator/flyway", "/**/actuator/liquibase",
            "/**/actuator/heapdump", "/**/actuator/loggers", "/**/actuator/auditevents", "/**/actuator/env/PID",
            "/**/actuator/jolokia/**", "/**/actuator/archaius/**", "/**/actuator/beans/**", "/**/actuator/httptrace",
            "/**/v2/api-docs/**", "/**/swagger-ui.html", "/**/swagger-resources/**", "/**/webjars/**", "/**/druid/**",
            "/**/actuator/hystrix.stream","/**/actuator/hystrix.stream**/**", "/**/turbine.stream", "/**/turbine.stream**/**",
            "/**/hystrix","/**/hystrix.stream", "/**/hystrix/**" ,"/**/hystrix/**/**" ,"/**/proxy.stream/**" ,"/**/favicon.ico" };

//    
//    private static final String[] ENDPOINTS = { 
//            "/**/actuator/**",
//            "/**/actuator/**/**",
//            "/**/v2/api-docs/**", 
//            "/**/swagger-ui.html", 
//            "/**/swagger-resources/**", 
//            "/**/webjars/**", 
//            "/**/druid/**",
//            "/**/turbine.stream", "/**/turbine.stream**/**",
//            "/**/hystrix","/**/hystrix.stream", "/**/hystrix/**" ,"/**/hystrix/**/**" ,
//            "/**/proxy.stream/**" ,
//            "/**/favicon.ico" };

    
    
    private List<Map<String, String>> routes = new ArrayList<>();
    
    public List<Map<String, String>> getRoutes() {
        return routes;
    }

    public void setRoutes(List<Map<String, String>> routes) {
        this.routes = routes;
    }
    
    private List<String> ignored = new ArrayList<>();

    public List<String> getIgnored() {
        return ignored;
    }

    public void setIgnored(List<String> ignored) {
        this.ignored = ignored;
    }

    public List<String> fetchIgnored() {
        //合并
        List<String> allList = Arrays.asList(ENDPOINTS);
        List<String> newList0 = new ArrayList(allList);
        List<String> newList1 = new ArrayList(ignored);
        newList1.addAll(newList0);
        return newList1;
    }
}
